#include "card.hpp"

Card::Card(std::string cardNum, std::string name, double balance) : cardNum(cardNum), name(name), balance(balance) {}

// Destructor is explicitly defaulted in the header file, no need to define it here.

std::string Card::getCardNum() const {
	return cardNum;
}
std::string Card::getName() const {
	return name;
}
double Card::getBalance() const {
	return balance;
}
bool Card::isLost() const {
	return lost;
}
void Card::consume(double amount) {
	if (balance >= amount) {
		balance -= amount;
		std::cout << "消费前余额: " << balance + amount << " 消费后余额: " << balance << std::endl;
	} else {
		std::cout << "对不起，您的饭卡余额不足，请及时充值!" << std::endl;
	}
	
}
void Card::recharge(double amount) {
	balance += amount;
	std::cout << "充值后余额: " << balance << std::endl;
}
void Card::reportLost() {
	lost = true;
}

// 添加移动构造函数和移动赋值运算符
Card::Card(Card&& other) noexcept : cardNum(std::move(other.cardNum)),
									name(std::move(other.name)),
									balance(other.balance),
									lost(other.lost)
									// 不需要移动 std::mutex，因为它不能被移动
{}
Card& Card::operator=(Card&& other) noexcept {
	if (this != &other)
	{
		cardNum = std::move(other.cardNum);
        name = std::move(other.name);
        balance = other.balance;
        lost = other.lost;
        // 不需要移动 std::mutex，因为它不能被移动
	}
	return *this;
}